//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for RDSDataService
public struct RDSDataServiceErrorType: AWSErrorType {
    enum Code: String {
        case badRequestException = "BadRequestException"
        case forbiddenException = "ForbiddenException"
        case internalServerErrorException = "InternalServerErrorException"
        case notFoundException = "NotFoundException"
        case serviceUnavailableError = "ServiceUnavailableError"
        case statementTimeoutException = "StatementTimeoutException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize RDSDataService
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// There is an error in the call or in a SQL statement.
    public static var badRequestException: Self { .init(.badRequestException) }
    /// There are insufficient privileges to make the call.
    public static var forbiddenException: Self { .init(.forbiddenException) }
    /// An internal error occurred.
    public static var internalServerErrorException: Self { .init(.internalServerErrorException) }
    /// The resourceArn, secretArn, or transactionId value can't be found.
    public static var notFoundException: Self { .init(.notFoundException) }
    /// The service specified by the resourceArn parameter is not available.
    public static var serviceUnavailableError: Self { .init(.serviceUnavailableError) }
    /// The execution of the SQL statement timed out.
    public static var statementTimeoutException: Self { .init(.statementTimeoutException) }
}

extension RDSDataServiceErrorType: Equatable {
    public static func == (lhs: RDSDataServiceErrorType, rhs: RDSDataServiceErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension RDSDataServiceErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
